home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1990-06-14 | 8.3 KB | [TEXT/MPS ] |
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary).
Confidence | Program | Detection | Match Type | Support
|
---|
66%
| dexvert
| Compact Compressed (Unix) (archive/compact)
| ext
| Supported |
10%
| dexvert
| MacBinary (archive/macBinary)
| fallback
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| MacBinary II, Thu Jun 14 16:29:09 1990, modified Thu Jun 14 16:29:09 1990, creator 'MPS ', type ASCII, 7711 bytes "Biomorph.c" , at 0x1e9f 488 bytes resource
| default (weak)
| |
99%
| file
| data
| default
| |
74%
| TrID
| Macintosh plain text (MacBinary)
| default
| |
25%
| TrID
| MacBinary 2
| default (weak)
| |
100%
| lsar
| MacBinary
| default
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [MPS ] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0a 42 69 6f 6d 6f 72 | 70 68 2e 63 00 00 00 00 |..Biomor|ph.c....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 50 53 | 20 00 00 00 00 00 00 00 |.TEXTMPS| .......|
|00000050| 00 00 00 00 00 1e 1f 00 | 00 01 e8 a2 9d a4 15 a2 |........|........|
|00000060| 9d a4 15 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 38 c2 00 00 |........|....8...|
|00000080| 65 70 20 3d 0d 09 09 09 | 09 09 28 52 55 4c 45 20 |ep =....|..(RULE |
|00000090| 2a 29 67 65 74 6d 65 6d | 28 73 69 7a 65 6f 66 28 |*)getmem|(sizeof(|
|000000a0| 52 55 4c 45 29 29 3b 0d | 09 09 09 09 66 69 6c 6c |RULE));.|....fill|
|000000b0| 6d 65 6d 28 20 52 75 6c | 65 70 2c 20 73 69 7a 65 |mem( Rul|ep, size|
|000000c0| 6f 66 28 52 55 4c 45 29 | 2c 20 30 20 29 3b 0d 09 |of(RULE)|, 0 );..|
|000000d0| 09 09 7d 0d 09 09 09 52 | 75 6c 65 70 2d 3e 61 63 |..}....R|ulep->ac|
|000000e0| 74 69 6f 6e 20 3d 20 67 | 65 74 6d 65 6d 28 20 6c |tion = g|etmem( l|
|000000f0| 65 6e 20 29 3b 0d 09 09 | 09 6d 6f 76 65 6d 65 6d |en );...|.movemem|
|00000100| 28 20 57 6f 72 6b 62 75 | 66 2c 20 52 75 6c 65 70 |( Workbu|f, Rulep|
|00000110| 2d 3e 61 63 74 69 6f 6e | 2c 20 6c 65 6e 20 29 3b |->action|, len );|
|00000120| 0d 09 09 7d 0d 09 09 65 | 6c 73 65 20 69 66 20 28 |...}...e|lse if (|
|00000130| 20 63 3d 3d 27 2c 27 20 | 29 0d 09 09 7b 0d 23 69 | c==',' |)...{.#i|
|00000140| 66 64 65 66 20 44 45 42 | 55 47 0d 09 09 09 69 66 |fdef DEB|UG....if|
|00000150| 20 28 20 44 65 62 75 67 | 20 29 0d 09 09 09 09 65 | ( Debug| ).....e|
|00000160| 72 72 6f 72 28 20 22 73 | 74 6f 70 20 70 61 74 74 |rror( "s|top patt|
|00000170| 65 72 6e 22 2c 20 30 20 | 29 3b 0d 23 65 6e 64 69 |ern", 0 |);.#endi|
|00000180| 66 0d 09 09 09 2f 2a 0d | 09 09 09 20 2a 20 49 74 |f..../*.|... * It|
|00000190| 27 73 20 28 68 6f 70 65 | 66 75 6c 6c 79 29 20 74 |'s (hope|fully) t|
|000001a0| 68 65 20 73 65 63 6f 6e | 64 20 70 61 72 74 20 6f |he secon|d part o|
|000001b0| 66 20 61 20 74 77 6f 2d | 70 61 72 74 0d 09 09 09 |f a two-|part....|
|000001c0| 20 2a 20 70 61 74 74 65 | 72 6e 20 73 74 72 69 6e | * patte|rn strin|
|000001d0| 67 2e 20 20 53 77 61 6c | 6c 6f 77 20 74 68 65 20 |g. Swal|low the |
|000001e0| 63 6f 6d 6d 61 20 61 6e | 64 20 73 74 61 72 74 0d |comma an|d start.|
|000001f0| 09 09 09 20 2a 20 63 6f | 6d 70 69 6c 69 6e 67 20 |... * co|mpiling |
|00000200| 61 6e 20 61 63 74 69 6f | 6e 20 73 74 72 69 6e 67 |an actio|n string|
|00000210| 2e 0d 09 09 09 20 2a 2f | 0d 09 09 09 69 66 20 28 |..... */|....if (|
|00000220| 20 21 52 75 6c 65 70 20 | 7c 7c 20 21 52 75 6c 65 | !Rulep ||| !Rule|
|00000230| 70 2d 3e 70 61 74 74 65 | 72 6e 2e 73 74 61 72 74 |p->patte|rn.start|
|00000240| 20 29 0d 09 09 09 09 65 | 72 72 6f 72 28 20 22 73 | ).....e|rror( "s|
|00000250| 74 6f 70 20 70 61 74 74 | 65 72 6e 20 77 69 74 68 |top patt|ern with|
|00000260| 6f 75 74 20 61 20 73 74 | 61 72 74 22 2c 0d 09 09 |out a st|art",...|
|00000270| 09 09 09 52 45 5f 45 52 | 52 4f 52 20 29 3b 0d 09 |...RE_ER|ROR );..|
|00000280| 09 09 69 66 20 28 20 52 | 75 6c 65 70 2d 3e 70 61 |..if ( R|ulep->pa|
|00000290| 74 74 65 72 6e 2e 73 74 | 6f 70 20 29 0d 09 09 09 |ttern.st|op )....|
|000002a0| 09 65 72 72 6f 72 28 20 | 22 61 6c 72 65 61 64 79 |.error( |"already|
|000002b0| 20 68 61 76 65 20 61 20 | 73 74 6f 70 20 70 61 74 | have a |stop pat|
|000002c0| 74 65 72 6e 22 2c 0d 09 | 09 09 09 09 52 45 5f 45 |tern",..|....RE_E|
|000002d0| 52 52 4f 52 20 29 3b 0d | 09 09 09 6c 65 6e 20 3d |RROR );.|...len =|
|000002e0| 20 70 61 74 5f 63 6f 6d | 70 69 6c 65 28 20 57 6f | pat_com|pile( Wo|
|000002f0| 72 6b 62 75 66 20 29 3b | 0d 09 09 09 52 75 6c 65 |rkbuf );|....Rule|
|00000300| 70 2d 3e 70 61 74 74 65 | 72 6e 2e 73 74 6f 70 20 |p->patte|rn.stop |
|00000310| 3d 20 67 65 74 6d 65 6d | 28 20 6c 65 6e 20 29 3b |= getmem|( len );|
|00000320| 0d 09 09 09 6d 6f 76 65 | 6d 65 6d 28 20 57 6f 72 |....move|mem( Wor|
|00000330| 6b 62 75 66 2c 20 52 75 | 6c 65 70 2d 3e 70 61 74 |kbuf, Ru|lep->pat|
|00000340| 74 65 72 6e 2e 73 74 6f | 70 2c 20 6c 65 6e 20 29 |tern.sto|p, len )|
|00000350| 3b 0d 09 09 7d 0d 09 09 | 65 6c 73 65 0d 09 09 7b |;...}...|else...{|
|00000360| 0d 09 09 09 2f 2a 0d 09 | 09 09 20 2a 20 41 73 73 |..../*..|.. * Ass|
|00000370| 75 6d 65 20 69 74 27 73 | 20 61 20 72 65 67 75 6c |ume it's| a regul|
|00000380| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 20 70 61 |ar expre|ssion pa|
|00000390| 74 74 65 72 6e 0d 09 09 | 09 20 2a 2f 0d 23 69 66 |ttern...|. */.#if|
|000003a0| 64 65 66 20 44 45 42 55 | 47 0d 09 09 09 69 66 20 |def DEBU|G....if |
|000003b0| 28 20 44 65 62 75 67 20 | 29 0d 09 09 09 09 65 72 |( Debug |).....er|
|000003c0| 72 6f 72 28 20 22 73 74 | 61 72 74 20 70 61 74 74 |ror( "st|art patt|
|000003d0| 65 72 6e 22 2c 20 30 20 | 29 3b 0d 23 65 6e 64 69 |ern", 0 |);.#endi|
|000003e0| 66 0d 0d 09 09 09 75 6e | 67 65 74 63 68 61 72 61 |f.....un|getchara|
|000003f0| 63 74 65 72 28 20 63 20 | 29 3b 0d 09 09 09 6c 65 |cter( c |);....le|
|00000400| 6e 20 3d 20 70 61 74 5f | 63 6f 6d 70 69 6c 65 28 |n = pat_|compile(|
|00000410| 20 57 6f 72 6b 62 75 66 | 20 29 3b 0d 0d 09 09 09 | Workbuf| );.....|
|00000420| 69 66 20 28 20 2a 57 6f | 72 6b 62 75 66 20 3d 3d |if ( *Wo|rkbuf ==|
|00000430| 20 54 5f 42 45 47 49 4e | 20 29 0d 09 09 09 7b 0d | T_BEGIN| )....{.|
|00000440| 09 09 09 09 2f 2a 0d 09 | 09 09 09 20 2a 20 53 61 |..../*..|... * Sa|
|00000450| 77 20 61 20 22 42 45 47 | 49 4e 22 20 6b 65 79 77 |w a "BEG|IN" keyw|
|00000460| 6f 72 64 20 2d 20 63 6f | 6d 70 69 6c 65 20 66 6f |ord - co|mpile fo|
|00000470| 6c 6c 6f 77 69 6e 67 0d | 09 09 09 09 20 2a 20 61 |llowing.|.... * a|
|00000480| 63 74 69 6f 6e 20 69 6e | 74 6f 20 73 70 65 63 69 |ction in|to speci|
|00000490| 61 6c 20 22 42 65 67 69 | 6e 61 63 74 22 20 62 75 |al "Begi|nact" bu|
|000004a0| 66 66 65 72 2e 0d 09 09 | 09 09 20 2a 2f 0d 09 09 |ffer....|.. */...|
|000004b0| 09 09 6c 65 6e 20 3d 20 | 61 63 74 5f 63 6f 6d 70 |..len = |act_comp|
|000004c0| 69 6c 65 28 20 57 6f 72 | 6b 62 75 66 20 29 3b 0d |ile( Wor|kbuf );.|
|000004d0| 09 09 09 09 42 65 67 69 | 6e 61 63 74 20 3d 20 67 |....Begi|nact = g|
|000004e0| 65 74 6d 65 6d 28 20 6c | 65 6e 20 29 3b 0d 09 09 |etmem( l|en );...|
|000004f0| 09 09 6d 6f 76 65 6d 65 | 6d 28 20 57 6f 72 6b 62 |..moveme|m( Workb|
|00000500| 75 66 2c 20 42 65 67 69 | 6e 61 63 74 2c 20 6c 65 |uf, Begi|nact, le|
|00000510| 6e 20 29 3b 0d 09 09 09 | 09 63 6f 6e 74 69 6e 75 |n );....|.continu|
|00000520| 65 3b 0d 09 09 09 7d 0d | 09 09 09 69 66 20 28 20 |e;....}.|...if ( |
|00000530| 2a 57 6f 72 6b 62 75 66 | 20 3d 3d 20 54 5f 45 4e |*Workbuf| == T_EN|
|00000540| 44 20 29 0d 09 09 09 7b | 0d 09 09 09 09 2f 2a 0d |D )....{|...../*.|
|00000550| 09 09 09 09 20 2a 20 53 | 61 77 20 61 6e 20 22 45 |.... * S|aw an "E|
|00000560| 4e 44 22 20 6b 65 79 77 | 6f 72 64 20 2d 20 63 6f |ND" keyw|ord - co|
|00000570| 6d 70 69 6c 65 20 66 6f | 6c 6c 6f 77 69 6e 67 0d |mpile fo|llowing.|
|00000580| 09 09 09 09 20 2a 20 61 | 63 74 69 6f 6e 20 69 6e |.... * a|ction in|
|00000590| 74 6f 20 73 70 65 63 69 | 61 6c 20 22 45 6e 64 61 |to speci|al "Enda|
|000005a0| 63 74 22 20 62 75 66 66 | 65 72 2e 0d 09 09 09 09 |ct" buff|er......|
|000005b0| 20 2a 2f 0d 09 09 09 09 | 6c 65 6e 20 3d 20 61 63 | */.....|len = ac|
|000005c0| 74 5f 63 6f 6d 70 69 6c | 65 28 20 57 6f 72 6b 62 |t_compil|e( Workb|
|000005d0| 75 66 20 29 3b 0d 09 09 | 09 09 45 6e 64 61 63 74 |uf );...|..Endact|
|000005e0| 20 3d 20 67 65 74 6d 65 | 6d 28 20 6c 65 6e 20 29 | = getme|m( len )|
|000005f0| 3b 0d 09 09 09 09 6d 6f | 76 65 6d 65 6d 28 20 57 |;.....mo|vemem( W|
|00000600| 6f 72 6b 62 75 66 2c 20 | 45 6e 64 61 63 74 2c 20 |orkbuf, |Endact, |
|00000610| 6c 65 6e 20 29 3b 0d 09 | 09 09 09 63 6f 6e 74 69 |len );..|...conti|
|00000620| 6e 75 65 3b 0d 09 09 09 | 7d 0d 09 09 09 69 66 20 |nue;....|}....if |
|00000630| 28 20 52 75 6c 65 70 20 | 29 0d 09 09 09 7b 0d 09 |( Rulep |)....{..|
|00000640| 09 09 09 2f 2a 0d 09 09 | 09 09 20 2a 20 41 6c 72 |.../*...|.. * Alr|
|00000650| 65 61 64 79 20 73 61 77 | 20 61 20 70 61 74 74 65 |eady saw| a patte|
|00000660| 72 6e 2f 61 63 74 69 6f | 6e 20 2d 20 6c 69 6e 6b |rn/actio|n - link|
|00000670| 20 69 6e 0d 09 09 09 09 | 20 2a 20 61 6e 6f 74 68 | in.....| * anoth|
|00000680| 65 72 20 52 75 6c 65 73 | 20 73 74 72 75 63 74 75 |er Rules| structu|
|00000690| 72 65 2e 0d 09 09 09 09 | 20 2a 2f 0d 09 09 09 09 |re......| */.....|
|000006a0| 52 75 6c 65 70 2d 3e 6e | 65 78 74 72 75 6c 65 20 |Rulep->n|extrule |
|000006b0| 3d 0d 09 09 09 09 09 28 | 52 55 4c 45 20 2a 29 67 |=......(|RULE *)g|
|000006c0| 65 74 6d 65 6d 28 73 69 | 7a 65 6f 66 28 52 55 4c |etmem(si|zeof(RUL|
|000006d0| 45 29 29 3b 0d 09 09 09 | 09 52 75 6c 65 70 20 3d |E));....|.Rulep =|
|000006e0| 20 52 75 6c 65 70 2d 3e | 6e 65 78 74 72 75 6c 65 | Rulep->|nextrule|
|000006f0| 3b 0d 09 09 09 09 66 69 | 6c 6c 6d 65 6d 28 20 52 |;.....fi|llmem( R|
|00000700| 75 6c 65 70 2c 20 73 69 | 7a 65 6f 66 28 52 55 4c |ulep, si|zeof(RUL|
|00000710| 45 29 2c 20 30 20 29 3b | 0d 09 09 09 7d 0d 09 09 |E), 0 );|....}...|
|00000720| 09 69 66 20 28 20 21 52 | 75 6c 65 70 20 29 0d 09 |.if ( !R|ulep )..|
|00000730| 09 09 7b 0d 09 09 09 09 | 2f 2a 0d 09 09 09 09 20 |..{.....|/*..... |
|00000740| 2a 20 54 68 69 73 20 69 | 73 20 74 68 65 20 66 69 |* This i|s the fi|
|00000750| 72 73 74 20 70 61 74 74 | 65 72 6e 20 65 6e 63 6f |rst patt|ern enco|
|00000760| 75 6e 74 65 72 65 64 2e | 0d 09 09 09 09 20 2a 20 |untered.|..... * |
|00000770| 41 6c 6c 6f 63 61 74 65 | 20 74 68 65 20 66 69 72 |Allocate| the fir|
|00000780| 73 74 20 52 75 6c 65 73 | 20 73 74 72 75 63 74 75 |st Rules| structu|
|00000790| 72 65 20 61 6e 64 0d 09 | 09 09 09 20 2a 20 69 6e |re and..|... * in|
|000007a0| 69 74 69 61 6c 69 7a 65 | 20 69 74 0d 09 09 09 09 |itialize| it.....|
|000007b0| 20 2a 2f 0d 09 09 09 09 | 52 75 6c 65 73 20 3d 20 | */.....|Rules = |
|000007c0| 52 75 6c 65 70 20 3d 0d | 09 09 09 09 09 28 52 55 |Rulep =.|.....(RU|
|000007d0| 4c 45 20 2a 29 67 65 74 | 6d 65 6d 28 73 69 7a 65 |LE *)get|mem(size|
|000007e0| 6f 66 28 52 55 4c 45 29 | 29 3b 0d 09 09 09 09 66 |of(RULE)|);.....f|
|000007f0| 69 6c 6c 6d 65 6d 28 20 | 52 75 6c 65 70 2c 20 73 |illmem( |Rulep, s|
|00000800| 69 7a 65 6f 66 28 52 55 | 4c 45 29 2c 20 30 20 29 |izeof(RU|LE), 0 )|
|00000810| 3b 0d 09 09 09 7d 0d 09 | 09 09 69 66 20 28 20 52 |;....}..|..if ( R|
|00000820| 75 6c 65 70 2d 3e 70 61 | 74 74 65 72 6e 2e 73 74 |ulep->pa|ttern.st|
|00000830| 61 72 74 20 29 0d 09 09 | 09 09 65 72 72 6f 72 28 |art )...|..error(|
|00000840| 20 22 61 6c 72 65 61 64 | 79 20 68 61 76 65 20 61 | "alread|y have a|
|00000850| 20 73 74 61 72 74 20 70 | 61 74 74 65 72 6e 22 2c | start p|attern",|
|00000860| 0d 09 09 09 09 09 52 45 | 5f 45 52 52 4f 52 20 29 |......RE|_ERROR )|
|00000870| 3b 0d 0d 09 09 09 52 75 | 6c 65 70 2d 3e 70 61 74 |;.....Ru|lep->pat|
|00000880| 74 65 72 6e 2e 73 74 61 | 72 74 20 3d 20 67 65 74 |tern.sta|rt = get|
|00000890| 6d 65 6d 28 20 6c 65 6e | 20 29 3b 0d 09 09 09 6d |mem( len| );....m|
|000008a0| 6f 76 65 6d 65 6d 28 20 | 57 6f 72 6b 62 75 66 2c |ovemem( |Workbuf,|
|000008b0| 20 52 75 6c 65 70 2d 3e | 70 61 74 74 65 72 6e 2e | Rulep->|pattern.|
|000008c0| 73 74 61 72 74 2c 20 6c | 65 6e 20 29 3b 0d 09 09 |start, l|en );...|
|000008d0| 7d 0d 09 7d 0d 09 65 6e | 64 66 69 6c 65 28 29 3b |}..}..en|dfile();|
|000008e0| 0d 7d 0d 0d 2f 2a 0d 20 | 2a 20 54 65 78 74 20 66 |.}../*. |* Text f|
|000008f0| 69 6c 65 20 6d 61 69 6e | 20 70 72 6f 63 65 73 73 |ile main| process|
|00000900| 69 6e 67 20 6c 6f 6f 70 | 2e 0d 20 2a 2f 0d 76 6f |ing loop|.. */.vo|
|00000910| 69 64 20 70 72 6f 63 65 | 73 73 28 29 0d 7b 0d 09 |id proce|ss().{..|
|00000920| 2f 2a 0d 09 20 2a 20 52 | 65 61 64 20 61 20 6c 69 |/*.. * R|ead a li|
|00000930| 6e 65 20 61 74 20 61 20 | 74 69 6d 65 20 66 72 6f |ne at a |time fro|
|00000940| 6d 20 63 75 72 72 65 6e | 74 20 69 6e 70 75 74 20 |m curren|t input |
|00000950| 66 69 6c 65 20 61 74 20 | 22 46 69 6c 65 70 74 72 |file at |"Fileptr|
|00000960| 22 2c 0d 09 20 2a 20 74 | 68 65 6e 20 61 70 70 6c |",.. * t|hen appl|
|00000970| 79 20 65 61 63 68 20 72 | 75 6c 65 20 69 6e 20 74 |y each r|ule in t|
|00000980| 68 65 20 52 75 6c 65 73 | 20 63 68 61 69 6e 20 74 |he Rules| chain t|
|00000990| 6f 20 74 68 65 20 69 6e | 70 75 74 20 6c 69 6e 65 |o the in|put line|
|000009a0| 2e 0d 09 20 2a 2f 0d 09 | 69 6e 74 20 69 3b 0d 0d |... */..|int i;..|
|000009b0| 23 69 66 64 65 66 20 44 | 45 42 55 47 0d 09 69 66 |#ifdef D|EBUG..if|
|000009c0| 20 28 20 44 65 62 75 67 | 20 29 0d 09 09 65 72 72 | ( Debug| )...err|
|000009d0| 6f 72 28 20 22 70 72 6f | 63 65 73 73 69 6e 67 2e |or( "pro|cessing.|
|000009e0| 2e 2e 22 2c 20 30 20 29 | 3b 0d 23 65 6e 64 69 66 |..", 0 )|;.#endif|
|000009f0| 0d 0d 09 52 65 63 6f 72 | 64 63 6f 75 6e 74 20 3d |...Recor|dcount =|
|00000a00| 20 30 3b 0d 0d 09 77 68 | 69 6c 65 20 28 20 67 65 | 0;...wh|ile ( ge|
|00000a10| 74 6c 69 6e 65 28 29 20 | 29 0d 09 7b 0d 09 09 2f |tline() |)..{.../|
|00000a20| 2a 0d 09 09 20 2a 20 50 | 61 72 73 65 20 74 68 65 |*... * P|arse the|
|00000a30| 20 69 6e 70 75 74 20 6c | 69 6e 65 2e 0d 09 09 20 | input l|ine.... |
|00000a40| 2a 2f 0d 09 09 46 69 65 | 6c 64 63 6f 75 6e 74 20 |*/...Fie|ldcount |
|00000a50| 3d 20 70 61 72 73 65 28 | 20 4c 69 6e 65 62 75 66 |= parse(| Linebuf|
|00000a60| 2c 20 46 69 65 6c 64 73 | 2c 20 46 6c 64 73 65 70 |, Fields|, Fldsep|
|00000a70| 20 29 3b 0d 23 69 66 64 | 65 66 20 44 45 42 55 47 | );.#ifd|ef DEBUG|
|00000a80| 0d 09 09 69 66 20 28 20 | 44 65 62 75 67 3e 31 20 |...if ( |Debug>1 |
|00000a90| 29 0d 09 09 7b 0d 09 09 | 09 70 72 69 6e 74 66 28 |)...{...|.printf(|
|00000aa0| 20 22 70 61 72 73 65 64 | 20 25 64 20 77 6f 72 64 | "parsed| %d word|
|00000ab0| 73 3a 5c 6e 22 2c 20 46 | 69 65 6c 64 63 6f 75 6e |s:\n", F|ieldcoun|
|00000ac0| 74 20 29 3b 0d 09 09 09 | 66 6f 72 28 69 3d 30 3b |t );....|for(i=0;|
|00000ad0| 20 69 3c 46 69 65 6c 64 | 63 6f 75 6e 74 3b 20 2b | i<Field|count; +|
|00000ae0| 2b 69 20 29 0d 09 09 09 | 09 70 72 69 6e 74 66 28 |+i )....|.printf(|
|00000af0| 20 22 3c 25 73 3e 5c 6e | 22 2c 20 46 69 65 6c 64 | "<%s>\n|", Field|
|00000b00| 73 5b 69 5d 20 29 3b 0d | 09 09 7d 0d 23 65 6e 64 |s[i] );.|..}.#end|
|00000b10| 69 66 0d 0d 09 09 52 75 | 6c 65 70 20 3d 20 52 75 |if....Ru|lep = Ru|
|00000b20| 6c 65 73 3b 0d 09 09 64 | 6f 0d 09 09 7b 0d 09 09 |les;...d|o...{...|
|00000b30| 09 69 66 20 28 20 21 20 | 52 75 6c 65 70 2d 3e 70 |.if ( ! |Rulep->p|
|00000b40| 61 74 74 65 72 6e 2e 73 | 74 61 72 74 20 29 0d 09 |attern.s|tart )..|
|00000b50| 09 09 7b 0d 09 09 09 09 | 2f 2a 0d 09 09 09 09 20 |..{.....|/*..... |
|00000b60| 2a 20 4e 6f 20 70 61 74 | 74 65 72 6e 20 67 69 76 |* No pat|tern giv|
|00000b70| 65 6e 20 2d 20 70 65 72 | 66 6f 72 6d 20 61 63 74 |en - per|form act|
|00000b80| 69 6f 6e 20 6f 6e 0d 09 | 09 09 09 20 2a 20 65 76 |ion on..|... * ev|
|00000b90| 65 72 79 20 69 6e 70 75 | 74 20 6c 69 6e 65 2e 0d |ery inpu|t line..|
|00000ba0| 09 09 09 09 20 2a 2f 0d | 09 09 09 09 64 6f 61 63 |.... */.|....doac|
|00000bb0| 74 69 6f 6e 28 20 52 75 | 6c 65 70 2d 3e 61 63 74 |tion( Ru|lep->act|
|00000bc0| 69 6f 6e 20 29 3b 0d 09 | 09 09 7d 0d 09 09 09 65 |ion );..|..}....e|
|00000bd0| 6c 73 65 20 69 66 20 28 | 20 52 75 6c 65 70 2d 3e |lse if (| Rulep->|
|00000be0| 70 61 74 74 65 72 6e 2e | 73 74 61 72 74 73 65 65 |pattern.|startsee|
|00000bf0| 6e 20 29 0d 09 09 09 7b | 0d 09 09 09 09 2f 2a 0d |n )....{|...../*.|
|00000c00| 09 09 09 09 20 2a 20 53 | 74 61 72 74 20 70 61 74 |.... * S|tart pat|
|00000c10| 74 65 72 6e 20 61 6c 72 | 65 61 64 79 20 66 6f 75 |tern alr|eady fou|
|00000c20| 6e 64 20 2d 20 70 65 72 | 66 6f 72 6d 0d 09 09 09 |nd - per|form....|
|00000c30| 09 20 2a 20 61 63 74 69 | 6f 6e 20 74 68 65 6e 20 |. * acti|on then |
|00000c40| 63 68 65 63 6b 20 69 66 | 20 6c 69 6e 65 20 6d 61 |check if| line ma|
|00000c50| 74 63 68 65 73 0d 09 09 | 09 09 20 2a 20 73 74 6f |tches...|.. * sto|
|00000c60| 70 20 70 61 74 74 65 72 | 6e 2e 0d 09 09 09 09 20 |p patter|n...... |
|00000c70| 2a 2f 0d 09 09 09 09 64 | 6f 61 63 74 69 6f 6e 28 |*/.....d|oaction(|
|00000c80| 20 52 75 6c 65 70 2d 3e | 61 63 74 69 6f 6e 20 29 | Rulep->|action )|
|00000c90| 3b 0d 09 09 09 09 69 66 | 20 28 20 64 6f 70 61 74 |;.....if| ( dopat|
|00000ca0| 74 65 72 6e 28 20 52 75 | 6c 65 70 2d 3e 70 61 74 |tern( Ru|lep->pat|
|00000cb0| 74 65 72 6e 2e 73 74 6f | 70 20 29 20 29 0d 09 09 |tern.sto|p ) )...|
|00000cc0| 09 09 09 52 75 6c 65 70 | 2d 3e 70 61 74 74 65 72 |...Rulep|->patter|
|00000cd0| 6e 2e 73 74 61 72 74 73 | 65 65 6e 20 3d 20 30 3b |n.starts|een = 0;|
|00000ce0| 0d 09 09 09 7d 0d 09 09 | 09 65 6c 73 65 20 69 66 |....}...|.else if|
|00000cf0| 20 28 20 64 6f 70 61 74 | 74 65 72 6e 28 20 52 75 | ( dopat|tern( Ru|
|00000d00| 6c 65 70 2d 3e 70 61 74 | 74 65 72 6e 2e 73 74 61 |lep->pat|tern.sta|
|00000d10| 72 74 20 29 20 29 0d 09 | 09 09 7b 0d 09 09 09 09 |rt ) )..|..{.....|
|00000d20| 2f 2a 0d 09 09 09 09 20 | 2a 20 4d 61 74 63 68 65 |/*..... |* Matche|
|00000d30| 64 20 73 74 61 72 74 20 | 70 61 74 74 65 72 6e 20 |d start |pattern |
|00000d40| 2d 20 70 65 72 66 6f 72 | 6d 20 61 63 74 69 6f 6e |- perfor|m action|
|00000d50| 2e 0d 09 09 09 09 20 2a | 20 49 66 20 61 20 73 74 |...... *| If a st|
|00000d60| 6f 70 20 70 61 74 74 65 | 72 6e 20 77 61 73 20 67 |op patte|rn was g|
|00000d70| 69 76 65 6e 2c 20 73 65 | 74 20 22 73 74 61 72 74 |iven, se|t "start|
|00000d80| 0d 09 09 09 09 20 2a 20 | 70 61 74 74 65 72 6e 20 |..... * |pattern |
|00000d90| 73 65 65 6e 22 20 66 6c | 61 67 20 61 6e 64 20 70 |seen" fl|ag and p|
|00000da0| 72 6f 63 65 73 73 20 65 | 76 65 72 79 20 69 6e 70 |rocess e|very inp|
|00000db0| 75 74 0d 09 09 09 09 20 | 2a 20 6c 69 6e 65 20 75 |ut..... |* line u|
|00000dc0| 6e 74 69 6c 20 73 74 6f | 70 20 70 61 74 74 65 72 |ntil sto|p patter|
|00000dd0| 6e 20 66 6f 75 6e 64 2e | 0d 09 09 09 09 20 2a 2f |n found.|..... */|
|00000de0| 0d 09 09 09 09 64 6f 61 | 63 74 69 6f 6e 28 20 52 |.....doa|ction( R|
|00000df0| 75 6c 65 70 2d 3e 61 63 | 74 69 6f 6e 20 29 3b 0d |ulep->ac|tion );.|
|00000e00| 09 09 09 09 69 66 20 28 | 20 52 75 6c 65 70 2d 3e |....if (| Rulep->|
|00000e10| 70 61 74 74 65 72 6e 2e | 73 74 6f 70 20 29 0d 09 |pattern.|stop )..|
|00000e20| 09 09 09 09 52 75 6c 65 | 70 2d 3e 70 61 74 74 65 |....Rule|p->patte|
|00000e30| 72 6e 2e 73 74 61 72 74 | 73 65 65 6e 20 3d 20 31 |rn.start|seen = 1|
|00000e40| 3b 0d 09 09 09 7d 0d 09 | 09 7d 0d 09 09 77 68 69 |;....}..|.}...whi|
|00000e50| 6c 65 20 28 20 52 75 6c | 65 70 20 3d 20 52 75 6c |le ( Rul|ep = Rul|
|00000e60| 65 70 2d 3e 6e 65 78 74 | 72 75 6c 65 20 29 3b 0d |ep->next|rule );.|
|00000e70| 0d 09 09 2f 2a 0d 09 09 | 20 2a 20 52 65 6c 65 61 |.../*...| * Relea|
|00000e80| 73 65 20 6d 65 6d 6f 72 | 79 20 61 6c 6c 6f 63 61 |se memor|y alloca|
|00000e90| 74 65 64 20 62 79 20 70 | 61 72 73 65 28 29 2e 0d |ted by p|arse()..|
|00000ea0| 09 09 20 2a 2f 0d 09 09 | 77 68 69 6c 65 20 28 20 |.. */...|while ( |
|00000eb0| 46 69 65 6c 64 63 6f 75 | 6e 74 20 29 0d 09 09 09 |Fieldcou|nt )....|
|00000ec0| 66 72 65 65 28 20 46 69 | 65 6c 64 73 5b 20 2d 2d |free( Fi|elds[ --|
|00000ed0| 46 69 65 6c 64 63 6f 75 | 6e 74 20 5d 20 29 3b 0d |Fieldcou|nt ] );.|
|00000ee0| 09 7d 0d 7d 0d 0d 2f 2a | 0d 20 2a 20 4d 69 73 63 |.}.}../*|. * Misc|
|00000ef0| 65 6c 6c 61 6e 65 6f 75 | 73 20 66 75 6e 63 74 69 |ellaneou|s functi|
|00000f00| 6f 6e 73 0d 20 2a 2f 0d | 69 6e 74 20 70 61 72 73 |ons. */.|int pars|
|00000f10| 65 28 20 73 74 72 2c 20 | 77 72 64 6c 73 74 2c 20 |e( str, |wrdlst, |
|00000f20| 64 65 6c 69 6d 20 29 0d | 63 68 61 72 20 2a 73 74 |delim ).|char *st|
|00000f30| 72 3b 0d 63 68 61 72 20 | 2a 77 72 64 6c 73 74 5b |r;.char |*wrdlst[|
|00000f40| 5d 3b 0d 63 68 61 72 20 | 2a 64 65 6c 69 6d 3b 0d |];.char |*delim;.|
|00000f50| 7b 0d 09 2f 2a 0d 09 20 | 2a 20 50 61 72 73 65 20 |{../*.. |* Parse |
|00000f60| 74 68 65 20 73 74 72 69 | 6e 67 20 6f 66 20 77 6f |the stri|ng of wo|
|00000f70| 72 64 73 20 69 6e 20 22 | 73 74 72 22 20 69 6e 74 |rds in "|str" int|
|00000f80| 6f 20 74 68 65 20 77 6f | 72 64 20 6c 69 73 74 20 |o the wo|rd list |
|00000f90| 61 74 20 22 77 72 64 6c | 73 74 22 2e 0d 09 20 2a |at "wrdl|st"... *|
|00000fa0| 20 41 20 22 77 6f 72 64 | 22 20 69 73 20 61 20 73 | A "word|" is a s|
|00000fb0| 65 71 75 65 6e 63 65 20 | 6f 66 20 63 68 61 72 61 |equence |of chara|
|00000fc0| 63 74 65 72 73 20 64 65 | 6c 69 6d 69 74 65 64 20 |cters de|limited |
|00000fd0| 62 79 20 6f 6e 65 20 6f | 72 20 6d 6f 72 65 0d 09 |by one o|r more..|
|00000fe0| 20 2a 20 6f 66 20 74 68 | 65 20 63 68 61 72 61 63 | * of th|e charac|
|00000ff0| 74 65 72 73 20 66 6f 75 | 6e 64 20 69 6e 20 74 68 |ters fou|nd in th|
|00001000| 65 20 73 74 72 69 6e 67 | 20 22 64 65 6c 69 6d 22 |e string| "delim"|
|00001010| 2e 0d 09 20 2a 20 52 65 | 74 75 72 6e 73 20 74 68 |... * Re|turns th|
|00001020| 65 20 6e 75 6d 62 65 72 | 20 6f 66 20 77 6f 72 64 |e number| of word|
|00001030| 73 20 70 61 72 73 65 64 | 2e 0d 09 20 2a 20 43 41 |s parsed|... * CA|
|00001040| 55 54 49 4f 4e 3a 20 74 | 68 65 20 6d 65 6d 6f 72 |UTION: t|he memor|
|00001050| 79 20 66 6f 72 20 74 68 | 65 20 77 6f 72 64 73 20 |y for th|e words |
|00001060| 69 6e 20 22 77 72 64 6c | 73 74 22 20 69 73 20 61 |in "wrdl|st" is a|
|00001070| 6c 6c 6f 63 61 74 65 64 | 0d 09 20 2a 20 62 79 20 |llocated|.. * by |
|00001080| 6d 61 6c 6c 6f 63 28 29 | 20 61 6e 64 20 73 68 6f |malloc()| and sho|
|00001090| 75 6c 64 20 65 76 65 6e | 74 75 61 6c 6c 79 20 62 |uld even|tually b|
|000010a0| 65 20 72 65 74 75 72 6e | 65 64 20 62 79 20 66 72 |e return|ed by fr|
|000010b0| 65 65 28 29 2e 2e 2e 0d | 09 20 2a 2f 0d 09 69 6e |ee()....|. */..in|
|000010c0| 74 20 77 72 64 63 6e 74 | 2c 20 77 72 64 6c 65 6e |t wrdcnt|, wrdlen|
|000010d0| 3b 0d 09 63 68 61 72 20 | 77 72 64 62 75 66 5b 20 |;..char |wrdbuf[ |
|000010e0| 4d 41 58 4c 49 4e 45 4c | 45 4e 20 5d 2c 20 63 3b |MAXLINEL|EN ], c;|
|000010f0| 0d 0d 09 77 72 64 63 6e | 74 20 3d 20 30 3b 0d 09 |...wrdcn|t = 0;..|
|00001100| 77 68 69 6c 65 20 28 20 | 2a 73 74 72 20 29 0d 09 |while ( |*str )..|
|00001110| 7b 0d 09 09 77 68 69 6c | 65 20 28 20 69 6e 73 74 |{...whil|e ( inst|
|00001120| 72 28 20 2a 73 74 72 2c | 20 64 65 6c 69 6d 20 29 |r( *str,| delim )|
|00001130| 20 29 0d 09 09 09 2b 2b | 73 74 72 3b 0d 09 09 69 | )....++|str;...i|
|00001140| 66 20 28 20 21 2a 73 74 | 72 20 29 0d 09 09 09 62 |f ( !*st|r )....b|
|00001150| 72 65 61 6b 3b 0d 09 09 | 77 72 64 6c 65 6e 20 3d |reak;...|wrdlen =|
|00001160| 20 30 3b 0d 09 09 77 68 | 69 6c 65 20 28 20 28 63 | 0;...wh|ile ( (c|
|00001170| 20 3d 20 2a 73 74 72 29 | 20 26 26 20 21 69 6e 73 | = *str)| && !ins|
|00001180| 74 72 28 20 63 2c 20 64 | 65 6c 69 6d 20 29 20 29 |tr( c, d|elim ) )|
|00001190| 0d 09 09 7b 0d 09 09 09 | 77 72 64 62 75 66 5b 20 |...{....|wrdbuf[ |
|000011a0| 77 72 64 6c 65 6e 2b 2b | 20 5d 20 3d 20 63 3b 0d |wrdlen++| ] = c;.|
|000011b0| 09 09 09 2b 2b 73 74 72 | 3b 0d 09 09 7d 0d 09 09 |...++str|;...}...|
|000011c0| 77 72 64 62 75 66 5b 20 | 77 72 64 6c 65 6e 2b 2b |wrdbuf[ |wrdlen++|
|000011d0| 20 5d 20 3d 20 30 3b 0d | 09 09 2f 2a 0d 09 09 20 | ] = 0;.|../*... |
|000011e0| 2a 20 4e 4f 54 45 3a 20 | 61 6c 6c 6f 63 61 74 65 |* NOTE: |allocate|
|000011f0| 20 61 20 4d 41 58 4c 49 | 4e 45 4c 45 4e 20 73 69 | a MAXLI|NELEN si|
|00001200| 7a 65 64 20 62 75 66 66 | 65 72 20 66 6f 72 20 65 |zed buff|er for e|
|00001210| 76 65 72 79 0d 09 09 20 | 2a 20 77 6f 72 64 2c 20 |very... |* word, |
|00001220| 6a 75 73 74 20 69 6e 20 | 63 61 73 65 20 75 73 65 |just in |case use|
|00001230| 72 20 77 61 6e 74 73 20 | 74 6f 20 63 6f 70 79 20 |r wants |to copy |
|00001240| 61 20 6c 61 72 67 65 72 | 20 73 74 72 69 6e 67 0d |a larger| string.|
|00001250| 09 09 20 2a 20 69 6e 74 | 6f 20 61 20 66 69 65 6c |.. * int|o a fiel|
|00001260| 64 2e 0d 09 09 20 2a 2f | 0d 09 09 77 72 64 6c 73 |d.... */|...wrdls|
|00001270| 74 5b 20 77 72 64 63 6e | 74 20 5d 20 3d 20 67 65 |t[ wrdcn|t ] = ge|
|00001280| 74 6d 65 6d 28 20 4d 41 | 58 4c 49 4e 45 4c 45 4e |tmem( MA|XLINELEN|
|00001290| 20 29 3b 0d 09 09 73 74 | 72 63 70 79 28 20 77 72 | );...st|rcpy( wr|
|000012a0| 64 6c 73 74 5b 20 77 72 | 64 63 6e 74 2b 2b 20 5d |dlst[ wr|dcnt++ ]|
|000012b0| 2c 20 77 72 64 62 75 66 | 20 29 3b 0d 09 7d 0d 0d |, wrdbuf| );..}..|
|000012c0| 09 72 65 74 75 72 6e 20 | 77 72 64 63 6e 74 3b 0d |.return |wrdcnt;.|
|000012d0| 7d 0d 0d 76 6f 69 64 20 | 75 6e 70 61 72 73 65 28 |}..void |unparse(|
|000012e0| 20 77 72 64 6c 73 74 2c | 20 77 72 64 63 6e 74 2c | wrdlst,| wrdcnt,|
|000012f0| 20 73 74 72 2c 20 64 65 | 6c 69 6d 20 29 0d 63 68 | str, de|lim ).ch|
|00001300| 61 72 20 2a 77 72 64 6c | 73 74 5b 5d 3b 0d 69 6e |ar *wrdl|st[];.in|
|00001310| 74 20 77 72 64 63 6e 74 | 3b 0d 63 68 61 72 20 2a |t wrdcnt|;.char *|
|00001320| 73 74 72 3b 0d 63 68 61 | 72 20 2a 64 65 6c 69 6d |str;.cha|r *delim|
|00001330| 3b 0d 7b 0d 09 2f 2a 0d | 09 20 2a 20 52 65 70 6c |;.{../*.|. * Repl|
|00001340| 61 63 65 20 61 6c 6c 20 | 74 68 65 20 77 6f 72 64 |ace all |the word|
|00001350| 73 20 69 6e 20 22 73 74 | 72 22 20 77 69 74 68 20 |s in "st|r" with |
|00001360| 74 68 65 20 77 6f 72 64 | 73 20 69 6e 20 22 77 72 |the word|s in "wr|
|00001370| 64 6c 73 74 22 2c 0d 09 | 20 2a 20 6d 61 69 6e 74 |dlst",..| * maint|
|00001380| 61 69 6e 69 6e 67 20 74 | 68 65 20 73 61 6d 65 20 |aining t|he same |
|00001390| 77 6f 72 64 20 73 65 70 | 65 72 61 74 69 6f 6e 20 |word sep|eration |
|000013a0| 64 69 73 74 61 6e 63 65 | 20 61 73 20 66 6f 75 6e |distance| as foun|
|000013b0| 64 20 69 6e 0d 09 20 2a | 20 74 68 65 20 73 74 72 |d in.. *| the str|
|000013c0| 69 6e 67 2e 0d 09 20 2a | 20 41 20 22 77 6f 72 64 |ing... *| A "word|
|000013d0| 22 20 69 73 20 61 20 73 | 65 71 75 65 6e 63 65 20 |" is a s|equence |
|000013e0| 6f 66 20 63 68 61 72 61 | 63 74 65 72 73 20 64 65 |of chara|cters de|
|000013f0| 6c 69 6d 69 74 65 64 20 | 62 79 20 6f 6e 65 20 6f |limited |by one o|
|00001400| 72 20 6d 6f 72 65 0d 09 | 20 2a 20 6f 66 20 74 68 |r more..| * of th|
|00001410| 65 20 63 68 61 72 61 63 | 74 65 72 73 20 66 6f 75 |e charac|ters fou|
|00001420| 6e 64 20 69 6e 20 74 68 | 65 20 73 74 72 69 6e 67 |nd in th|e string|
|00001430| 20 22 64 65 6c 69 6d 22 | 2e 0d 09 20 2a 2f 0d 09 | "delim"|... */..|
|00001440| 69 6e 74 20 77 63 3b 0d | 09 63 68 61 72 20 73 74 |int wc;.|.char st|
|00001450| 72 62 75 66 5b 20 4d 41 | 58 4c 49 4e 45 4c 45 4e |rbuf[ MA|XLINELEN|
|00001460| 20 5d 2c 20 2a 73 70 2c | 20 2a 77 70 2c 20 2a 73 | ], *sp,| *wp, *s|
|00001470| 74 61 72 74 3b 0d 0d 09 | 77 63 20 3d 20 30 3b 09 |tart;...|wc = 0;.|
|00001480| 09 2f 2a 20 6e 65 78 74 | 20 77 6f 72 64 20 69 6e |./* next| word in|
|00001490| 20 22 77 72 64 6c 73 74 | 22 20 2a 2f 0d 09 73 70 | "wrdlst|" */..sp|
|000014a0| 20 3d 20 73 74 72 62 75 | 66 3b 09 2f 2a 20 70 6f | = strbu|f;./* po|
|000014b0| 69 6e 74 73 20 74 6f 20 | 6f 75 72 20 6c 6f 63 61 |ints to |our loca|
|000014c0| 6c 20 73 74 72 69 6e 67 | 20 2a 2f 0d 09 73 74 61 |l string| */..sta|
|000014d0| 72 74 20 3d 20 73 74 72 | 3b 09 2f 2a 20 73 61 76 |rt = str|;./* sav|
|000014e0| 65 20 73 74 61 72 74 20 | 61 64 64 72 65 73 73 20 |e start |address |
|000014f0| 6f 66 20 22 73 74 72 22 | 20 66 6f 72 20 6c 61 74 |of "str"| for lat|
|00001500| 65 72 2e 2e 2e 20 2a 2f | 0d 09 77 68 69 6c 65 20 |er... */|..while |
|00001510| 28 20 2a 73 74 72 20 29 | 0d 09 7b 0d 09 09 2f 2a |( *str )|..{.../*|
|00001520| 0d 09 09 20 2a 20 43 6f | 70 79 20 74 68 65 20 66 |... * Co|py the f|
|00001530| 69 65 6c 64 20 64 65 6c | 69 6d 69 74 65 72 73 20 |ield del|imiters |
|00001540| 66 72 6f 6d 20 74 68 65 | 20 6f 72 69 67 69 6e 61 |from the| origina|
|00001550| 6c 20 73 74 72 69 6e 67 | 20 74 6f 0d 09 09 20 2a |l string| to... *|
|00001560| 20 6f 75 72 20 6c 6f 63 | 61 6c 20 76 65 72 73 69 | our loc|al versi|
|00001570| 6f 6e 2e 0d 09 09 20 2a | 2f 0d 09 09 77 68 69 6c |on.... *|/...whil|
|00001580| 65 20 28 20 69 6e 73 74 | 72 28 20 2a 73 74 72 2c |e ( inst|r( *str,|
|00001590| 20 64 65 6c 69 6d 20 29 | 20 29 0d 09 09 09 2a 73 | delim )| )....*s|
|000015a0| 70 2b 2b 20 3d 20 2a 73 | 74 72 2b 2b 3b 0d 09 09 |p++ = *s|tr++;...|
|000015b0| 69 66 20 28 20 21 2a 73 | 74 72 20 29 0d 09 09 09 |if ( !*s|tr )....|
|000015c0| 62 72 65 61 6b 3b 0d 09 | 09 2f 2a 0d 09 09 20 2a |break;..|./*... *|
|000015d0| 20 53 6b 69 70 20 6f 76 | 65 72 20 74 68 65 20 66 | Skip ov|er the f|
|000015e0| 69 65 6c 64 20 69 6e 20 | 74 68 65 20 6f 72 69 67 |ield in |the orig|
|000015f0| 69 6e 61 6c 20 73 74 72 | 69 6e 67 20 61 6e 64 2e |inal str|ing and.|
|00001600| 2e 2e 0d 09 09 20 2a 2f | 0d 09 09 77 68 69 6c 65 |..... */|...while|
|00001610| 20 28 20 2a 73 74 72 20 | 26 26 20 21 69 6e 73 74 | ( *str |&& !inst|
|00001620| 72 28 20 2a 73 74 72 2c | 20 64 65 6c 69 6d 20 29 |r( *str,| delim )|
|00001630| 20 29 0d 09 09 09 2b 2b | 73 74 72 3b 0d 0d 09 09 | )....++|str;....|
|00001640| 69 66 20 28 20 77 63 20 | 3c 20 77 72 64 63 6e 74 |if ( wc |< wrdcnt|
|00001650| 20 29 0d 09 09 7b 0d 09 | 09 09 2f 2a 0d 09 09 09 | )...{..|../*....|
|00001660| 20 2a 20 2e 2e 2e 63 6f | 70 79 20 69 6e 20 74 68 | * ...co|py in th|
|00001670| 65 20 66 69 65 6c 64 20 | 69 6e 20 74 68 65 20 77 |e field |in the w|
|00001680| 6f 72 64 6c 69 73 74 20 | 69 6e 73 74 65 61 64 2e |ordlist |instead.|
|00001690| 0d 09 09 09 20 2a 2f 0d | 09 09 09 77 70 20 3d 20 |.... */.|...wp = |
|000016a0| 77 72 64 6c 73 74 5b 20 | 77 63 2b 2b 20 5d 3b 0d |wrdlst[ |wc++ ];.|
|000016b0| 09 09 09 77 68 69 6c 65 | 20 28 20 2a 77 70 20 29 |...while| ( *wp )|
|000016c0| 0d 09 09 09 09 2a 73 70 | 2b 2b 20 3d 20 2a 77 70 |.....*sp|++ = *wp|
|000016d0| 2b 2b 3b 0d 09 09 7d 0d | 09 7d 0d 09 2f 2a 0d 09 |++;...}.|.}../*..|
|000016e0| 20 2a 20 54 69 65 20 6f | 66 66 20 74 68 65 20 6c | * Tie o|ff the l|
|000016f0| 6f 63 61 6c 20 73 74 72 | 69 6e 67 2c 20 74 68 65 |ocal str|ing, the|
|00001700| 6e 20 63 6f 70 79 20 69 | 74 20 62 61 63 6b 20 74 |n copy i|t back t|
|00001710| 6f 20 63 61 6c 6c 65 72 | 27 73 20 73 74 72 69 6e |o caller|'s strin|
|00001720| 67 2e 0d 09 20 2a 2f 0d | 09 2a 73 70 20 3d 20 30 |g... */.|.*sp = 0|
|00001730| 3b 0d 09 73 74 72 63 70 | 79 28 20 73 74 61 72 74 |;..strcp|y( start|
|00001740| 2c 20 73 74 72 62 75 66 | 20 29 3b 0d 7d 0d 0d 69 |, strbuf| );.}..i|
|00001750| 6e 74 20 69 6e 73 74 72 | 28 20 63 2c 20 73 20 29 |nt instr|( c, s )|
|00001760| 0d 63 68 61 72 20 63 2c | 20 2a 73 3b 0d 7b 0d 09 |.char c,| *s;.{..|
|00001770| 77 68 69 6c 65 20 28 20 | 2a 73 20 29 0d 09 09 69 |while ( |*s )...i|
|00001780| 66 20 28 20 63 3d 3d 2a | 73 2b 2b 20 29 0d 09 09 |f ( c==*|s++ )...|
|00001790| 09 72 65 74 75 72 6e 20 | 31 3b 0d 09 72 65 74 75 |.return |1;..retu|
|000017a0| 72 6e 20 30 3b 0d 7d 0d | 0d 63 68 61 72 20 2a 67 |rn 0;.}.|.char *g|
|000017b0| 65 74 6d 65 6d 28 20 6c | 65 6e 20 29 0d 75 6e 73 |etmem( l|en ).uns|
|000017c0| 69 67 6e 65 64 20 6c 65 | 6e 3b 0d 7b 0d 09 63 68 |igned le|n;.{..ch|
|000017d0| 61 72 20 2a 63 70 3b 0d | 0d 09 69 66 20 28 63 70 |ar *cp;.|..if (cp|
|000017e0| 20 3d 20 6d 61 6c 6c 6f | 63 28 6c 65 6e 29 29 20 | = mallo|c(len)) |
|000017f0| 72 65 74 75 72 6e 20 63 | 70 3b 0d 09 65 72 72 6f |return c|p;..erro|
|00001800| 72 28 20 22 6f 75 74 20 | 6f 66 20 6d 65 6d 6f 72 |r( "out |of memor|
|00001810| 79 22 2c 20 4d 45 4d 5f | 45 52 52 4f 52 20 29 3b |y", MEM_|ERROR );|
|00001820| 0d 7d 0d 0d 76 6f 69 64 | 20 6e 65 77 66 69 6c 65 |.}..void| newfile|
|00001830| 28 73 29 0d 63 68 61 72 | 20 2a 73 3b 0d 7b 0d 09 |(s).char| *s;.{..|
|00001840| 4c 69 6e 65 63 6f 75 6e | 74 20 3d 20 30 3b 0d 09 |Linecoun|t = 0;..|
|00001850| 69 66 20 28 20 46 69 6c | 65 6e 61 6d 65 20 3d 20 |if ( Fil|ename = |
|00001860| 73 20 29 0d 09 7b 0d 09 | 09 69 66 20 28 20 21 28 |s )..{..|.if ( !(|
|00001870| 46 69 6c 65 70 74 72 20 | 3d 20 66 6f 70 65 6e 28 |Fileptr |= fopen(|
|00001880| 20 73 2c 20 22 72 22 20 | 29 29 20 29 0d 09 09 09 | s, "r" |)) )....|
|00001890| 65 72 72 6f 72 28 20 22 | 66 69 6c 65 20 6e 6f 74 |error( "|file not|
|000018a0| 20 66 6f 75 6e 64 22 2c | 20 46 49 4c 45 5f 45 52 | found",| FILE_ER|
|000018b0| 52 4f 52 20 29 3b 0d 09 | 7d 0d 09 65 6c 73 65 0d |ROR );..|}..else.|
|000018c0| 09 7b 0d 09 09 2f 2a 0d | 09 09 20 2a 20 4e 6f 20 |.{.../*.|.. * No |
|000018d0| 66 69 6c 65 20 6e 61 6d | 65 20 67 69 76 65 6e 20 |file nam|e given |
|000018e0| 2d 20 70 72 6f 63 65 73 | 73 20 73 74 61 6e 64 61 |- proces|s standa|
|000018f0| 72 64 20 69 6e 70 75 74 | 2e 0d 09 09 20 2a 2f 0d |rd input|.... */.|
|00001900| 09 09 46 69 6c 65 70 74 | 72 20 3d 20 73 74 64 69 |..Filept|r = stdi|
|00001910| 6e 3b 0d 09 09 46 69 6c | 65 6e 61 6d 65 20 3d 20 |n;...Fil|ename = |
|00001920| 22 73 74 61 6e 64 61 72 | 64 20 69 6e 70 75 74 22 |"standar|d input"|
|00001930| 3b 0d 09 7d 0d 7d 0d 0d | 69 6e 74 20 67 65 74 6c |;..}.}..|int getl|
|00001940| 69 6e 65 28 29 0d 7b 0d | 09 2f 2a 0d 09 20 2a 20 |ine().{.|./*.. * |
|00001950| 52 65 61 64 20 61 20 6c | 69 6e 65 20 6f 66 20 74 |Read a l|ine of t|
|00001960| 65 78 74 20 66 72 6f 6d | 20 63 75 72 72 65 6e 74 |ext from| current|
|00001970| 20 69 6e 70 75 74 20 66 | 69 6c 65 2e 09 20 53 74 | input f|ile.. St|
|00001980| 72 69 70 20 6f 66 66 0d | 09 20 2a 20 74 72 61 69 |rip off.|. * trai|
|00001990| 6c 69 6e 67 20 72 65 63 | 6f 72 64 20 73 65 70 65 |ling rec|ord sepe|
|000019a0| 72 61 74 6f 72 20 28 6e | 65 77 6c 69 6e 65 29 2e |rator (n|ewline).|
|000019b0| 0d 09 20 2a 2f 0d 09 69 | 6e 74 20 72 74 6e 2c 20 |.. */..i|nt rtn, |
|000019c0| 6c 65 6e 3b 0d 0d 09 66 | 6f 72 20 28 20 6c 65 6e |len;...f|or ( len|
|000019d0| 3d 30 3b 20 6c 65 6e 3c | 4d 41 58 4c 49 4e 45 4c |=0; len<|MAXLINEL|
|000019e0| 45 4e 3b 20 2b 2b 6c 65 | 6e 20 29 0d 09 7b 0d 09 |EN; ++le|n )..{..|
|000019f0| 09 69 66 20 28 20 28 72 | 74 6e 20 3d 20 67 65 74 |.if ( (r|tn = get|
|00001a00| 63 68 61 72 61 63 74 65 | 72 28 29 29 20 3d 3d 20 |characte|r()) == |
|00001a10| 2a 52 63 72 64 73 65 70 | 20 7c 7c 20 72 74 6e 20 |*Rcrdsep| || rtn |
|00001a20| 3d 3d 20 2d 31 20 29 0d | 09 09 09 62 72 65 61 6b |== -1 ).|...break|
|00001a30| 3b 0d 09 09 4c 69 6e 65 | 62 75 66 5b 20 6c 65 6e |;...Line|buf[ len|
|00001a40| 20 5d 20 3d 20 72 74 6e | 3b 0d 09 7d 0d 09 4c 69 | ] = rtn|;..}..Li|
|00001a50| 6e 65 62 75 66 5b 20 6c | 65 6e 20 5d 20 3d 20 30 |nebuf[ l|en ] = 0|
|00001a60| 3b 0d 0d 09 69 66 20 28 | 20 72 74 6e 20 3d 3d 20 |;...if (| rtn == |
|00001a70| 2d 31 20 29 0d 09 7b 0d | 09 09 65 6e 64 66 69 6c |-1 )..{.|..endfil|
|00001a80| 65 28 29 3b 0d 09 09 72 | 65 74 75 72 6e 20 30 3b |e();...r|eturn 0;|
|00001a90| 0d 09 7d 0d 09 72 65 74 | 75 72 6e 20 31 3b 0d 7d |..}..ret|urn 1;.}|
|00001aa0| 0d 0d 69 6e 74 20 67 65 | 74 63 68 61 72 61 63 74 |..int ge|tcharact|
|00001ab0| 65 72 28 29 0d 7b 0d 09 | 2f 2a 0d 09 20 2a 20 52 |er().{..|/*.. * R|
|00001ac0| 65 61 64 20 61 20 63 68 | 61 72 61 63 74 65 72 20 |ead a ch|aracter |
|00001ad0| 66 72 6f 6d 20 63 75 72 | 72 65 6e 20 69 6e 70 75 |from cur|ren inpu|
|00001ae0| 74 20 66 69 6c 65 2e 0d | 09 20 2a 20 57 41 52 4e |t file..|. * WARN|
|00001af0| 49 4e 47 3a 20 79 6f 75 | 72 20 67 65 74 63 28 29 |ING: you|r getc()|
|00001b00| 20 6d 75 73 74 20 63 6f | 6e 76 65 72 74 20 6c 69 | must co|nvert li|
|00001b10| 6e 65 73 20 74 68 61 74 | 20 65 6e 64 20 77 69 74 |nes that| end wit|
|00001b20| 68 20 43 52 2b 4c 46 0d | 09 20 2a 20 74 6f 20 4c |h CR+LF.|. * to L|
|00001b30| 46 20 61 6e 64 20 45 4f | 46 20 6d 61 72 6b 73 20 |F and EO|F marks |
|00001b40| 28 6c 69 6b 65 20 43 50 | 2f 4d 27 73 20 5e 5a 29 |(like CP|/M's ^Z)|
|00001b50| 20 74 6f 20 61 20 2d 31 | 2e 0d 09 20 2a 20 41 6c | to a -1|... * Al|
|00001b60| 73 6f 2c 20 67 65 74 63 | 28 29 20 6d 75 73 74 20 |so, getc|() must |
|00001b70| 72 65 74 75 72 6e 20 61 | 20 2d 31 20 77 68 65 6e |return a| -1 when|
|00001b80| 20 61 74 74 65 6d 70 74 | 69 6e 67 20 74 6f 20 72 | attempt|ing to r|
|00001b90| 65 61 64 20 66 72 6f 6d | 0d 09 20 2a 20 61 6e 20 |ead from|.. * an |
|00001ba0| 75 6e 6f 70 65 6e 65 64 | 20 66 69 6c 65 2e 0d 09 |unopened| file...|
|00001bb0| 20 2a 2f 0d 09 69 6e 74 | 20 63 3b 0d 0d 09 69 66 | */..int| c;...if|
|00001bc0| 20 28 28 63 20 3d 20 67 | 65 74 63 28 46 69 6c 65 | ((c = g|etc(File|
|00001bd0| 70 74 72 29 29 20 3d 3d | 20 2a 52 63 72 64 73 65 |ptr)) ==| *Rcrdse|
|00001be0| 70 20 29 0d 09 09 2b 2b | 52 65 63 6f 72 64 63 6f |p )...++|Recordco|
|00001bf0| 75 6e 74 3b 0d 09 69 66 | 20 28 20 63 3d 3d 27 5c |unt;..if| ( c=='\|
|00001c00| 6e 27 20 29 0d 09 09 2b | 2b 4c 69 6e 65 63 6f 75 |n' )...+|+Linecou|
|00001c10| 6e 74 3b 0d 0d 09 72 65 | 74 75 72 6e 20 63 3b 0d |nt;...re|turn c;.|
|00001c20| 7d 0d 0d 69 6e 74 20 75 | 6e 67 65 74 63 68 61 72 |}..int u|ngetchar|
|00001c30| 61 63 74 65 72 28 20 63 | 20 29 0d 7b 0d 09 2f 2a |acter( c| ).{../*|
|00001c40| 0d 09 20 2a 20 50 75 73 | 68 20 61 20 63 68 61 72 |.. * Pus|h a char|
|00001c50| 61 63 74 65 72 20 62 61 | 63 6b 20 69 6e 74 6f 20 |acter ba|ck into |
|00001c60| 74 68 65 20 69 6e 70 75 | 74 20 73 74 72 65 61 6d |the inpu|t stream|
|00001c70| 2e 0d 09 20 2a 20 49 66 | 20 74 68 65 20 63 68 61 |... * If| the cha|
|00001c80| 72 61 63 74 65 72 20 69 | 73 20 61 20 72 65 63 6f |racter i|s a reco|
|00001c90| 72 64 20 73 65 70 65 72 | 61 74 6f 72 2c 20 6f 72 |rd seper|ator, or|
|00001ca0| 20 61 20 6e 65 77 6c 69 | 6e 65 20 63 68 61 72 61 | a newli|ne chara|
|00001cb0| 63 74 65 72 2c 0d 09 20 | 2a 20 74 68 65 20 72 65 |cter,.. |* the re|
|00001cc0| 63 6f 72 64 20 61 6e 64 | 20 6c 69 6e 65 20 63 6f |cord and| line co|
|00001cd0| 75 6e 74 65 72 73 20 61 | 72 65 20 61 64 6a 75 73 |unters a|re adjus|
|00001ce0| 74 65 64 20 61 70 70 72 | 6f 70 72 69 61 74 65 6c |ted appr|opriatel|
|00001cf0| 79 2e 0d 09 20 2a 2f 0d | 09 69 66 20 28 20 63 20 |y... */.|.if ( c |
|00001d00| 3d 3d 20 2a 52 63 72 64 | 73 65 70 20 29 0d 09 09 |== *Rcrd|sep )...|
|00001d10| 2d 2d 52 65 63 6f 72 64 | 63 6f 75 6e 74 3b 0d 09 |--Record|count;..|
|00001d20| 69 66 20 28 20 63 3d 3d | 27 5c 6e 27 20 29 0d 09 |if ( c==|'\n' )..|
|00001d30| 09 2d 2d 4c 69 6e 65 63 | 6f 75 6e 74 3b 0d 09 72 |.--Linec|ount;..r|
|00001d40| 65 74 75 72 6e 20 75 6e | 67 65 74 63 28 20 63 2c |eturn un|getc( c,|
|00001d50| 20 46 69 6c 65 70 74 72 | 20 29 3b 0d 7d 0d 0d 76 | Fileptr| );.}..v|
|00001d60| 6f 69 64 20 65 6e 64 66 | 69 6c 65 28 29 0d 7b 0d |oid endf|ile().{.|
|00001d70| 09 66 63 6c 6f 73 65 28 | 20 46 69 6c 65 70 74 72 |.fclose(| Fileptr|
|00001d80| 20 29 3b 0d 09 46 69 6c | 65 6e 61 6d 65 20 3d 20 | );..Fil|ename = |
|00001d90| 4e 55 4c 4c 3b 20 20 4c | 69 6e 65 63 6f 75 6e 74 |NULL; L|inecount|
|00001da0| 20 3d 20 30 3b 0d 7d 0d | 0d 76 6f 69 64 20 65 72 | = 0;.}.|.void er|
|00001db0| 72 6f 72 28 20 73 2c 20 | 73 65 76 65 72 65 20 29 |ror( s, |severe )|
|00001dc0| 0d 63 68 61 72 20 2a 73 | 3b 0d 69 6e 74 20 73 65 |.char *s|;.int se|
|00001dd0| 76 65 72 65 3b 0d 7b 0d | 09 69 66 20 28 20 46 69 |vere;.{.|.if ( Fi|
|00001de0| 6c 65 6e 61 6d 65 20 29 | 0d 09 09 66 70 72 69 6e |lename )|...fprin|
|00001df0| 74 66 28 20 73 74 64 65 | 72 72 2c 20 22 25 73 3a |tf( stde|rr, "%s:|
|00001e00| 22 2c 20 46 69 6c 65 6e | 61 6d 65 20 29 3b 0d 0d |", Filen|ame );..|
|00001e10| 09 69 66 20 28 20 4c 69 | 6e 65 63 6f 75 6e 74 20 |.if ( Li|necount |
|00001e20| 29 0d 09 09 66 70 72 69 | 6e 74 66 28 20 73 74 64 |)...fpri|ntf( std|
|00001e30| 65 72 72 2c 20 22 20 6c | 69 6e 65 20 25 64 3a 22 |err, " l|ine %d:"|
|00001e40| 2c 20 4c 69 6e 65 63 6f | 75 6e 74 20 29 3b 0d 0d |, Lineco|unt );..|
|00001e50| 09 66 70 72 69 6e 74 66 | 28 20 73 74 64 65 72 72 |.fprintf|( stderr|
|00001e60| 2c 20 22 20 25 73 5c 6e | 22 2c 20 73 20 29 3b 0d |, " %s\n|", s );.|
|00001e70| 09 69 66 20 28 20 73 65 | 76 65 72 65 20 29 0d 09 |.if ( se|vere )..|
|00001e80| 09 65 78 69 74 28 20 73 | 65 76 65 72 65 20 29 3b |.exit( s|evere );|
|00001e90| 0d 7d 0d 0d 76 6f 69 64 | 20 75 73 61 67 65 28 00 |.}..void| usage(.|
|00001ea0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001eb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ec0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ed0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ee0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ef0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001f00| 6f 20 6f 75 72 0d 09 09 | 09 20 2a 20 67 6c 6f 62 |o our...|. * glob|
|00001f10| 61 6c 20 77 6f 72 6b 20 | 62 75 66 66 65 72 2c 20 |al work |buffer, |
|00001f20| 74 68 65 6e 20 61 6c 6c | 6f 63 61 74 65 20 73 6f |then all|ocate so|
|00001f30| 6d 65 20 6d 65 6d 6f 72 | 79 0d 09 09 09 20 2a 20 |me memor|y.... * |
|00001f40| 66 6f 72 20 69 74 20 61 | 6e 64 20 63 6f 70 79 20 |for it a|nd copy |
|00001f50| 69 74 20 6f 76 65 72 2e | 0d 09 09 09 20 2a 2f 0d |it over.|.... */.|
|00001f60| 09 09 09 75 6e 67 65 74 | 63 68 61 72 61 63 74 65 |...unget|characte|
|00001f70| 72 28 20 27 7b 27 20 29 | 3b 0d 09 09 09 6c 65 6e |r( '{' )|;....len|
|00001f80| 20 3d 20 61 63 74 5f 63 | 6f 6d 70 69 6c 65 28 20 | = act_c|ompile( |
|00001f90| 57 6f 72 6b 62 75 66 20 | 29 3b 0d 0d 09 09 09 69 |Workbuf |);.....i|
|00001fa0| 66 20 28 20 52 75 6c 65 | 70 20 26 26 20 52 75 6c |f ( Rule|p && Rul|
|00001fb0| 65 70 2d 3e 61 63 74 69 | 6f 6e 20 29 0d 09 09 09 |ep->acti|on )....|
|00001fc0| 7b 0d 09 09 09 09 52 75 | 6c 65 70 2d 3e 6e 65 78 |{.....Ru|lep->nex|
|00001fd0| 74 72 75 6c 65 20 3d 0d | 09 09 09 09 09 28 52 55 |trule =.|.....(RU|
|00001fe0| 4c 45 20 2a 29 67 65 74 | 6d 65 6d 28 73 69 7a 65 |LE *)get|mem(size|
|00001ff0| 6f 66 28 52 55 4c 45 29 | 29 3b 0d 09 09 09 09 52 |of(RULE)|);.....R|
|00002000| 75 6c 65 70 20 3d 20 52 | 75 6c 65 70 2d 3e 6e 65 |ulep = R|ulep->ne|
|00002010| 78 74 72 75 6c 65 3b 0d | 09 09 09 09 66 69 6c 6c |xtrule;.|....fill|
|00002020| 6d 65 6d 28 20 52 75 6c | 65 70 2c 20 73 69 7a 65 |mem( Rul|ep, size|
|00002030| 6f 66 28 52 55 4c 45 29 | 2c 20 30 20 29 3b 0d 09 |of(RULE)|, 0 );..|
|00002040| 09 09 7d 0d 09 09 09 69 | 66 20 28 20 21 52 75 6c |..}....i|f ( !Rul|
|00002050| 65 70 20 29 0d 09 09 09 | 7b 0d 09 09 09 09 2f 2a |ep )....|{...../*|
|00002060| 0d 09 09 09 09 20 2a 20 | 54 68 69 73 20 69 73 20 |..... * |This is |
|00002070| 74 68 65 20 66 69 72 73 | 74 20 61 63 74 69 6f 6e |the firs|t action|
|00002080| 20 65 6e 63 6f 75 6e 74 | 65 72 65 64 2e 0d 09 09 | encount|ered....|
|00002090| 09 09 20 2a 20 41 6c 6c | 6f 63 61 74 65 20 74 68 |.. * All|ocate th|
|000020a0| 65 20 66 69 72 73 74 20 | 52 75 6c 65 73 20 73 74 |e first |Rules st|
|000020b0| 72 75 63 74 75 72 65 20 | 61 6e 64 0d 09 09 09 09 |ructure |and.....|
|000020c0| 20 2a 20 69 6e 69 74 69 | 61 6c 69 7a 65 20 69 74 | * initi|alize it|
|000020d0| 0d 09 09 09 09 20 2a 2f | 0d 09 09 09 09 52 75 6c |..... */|.....Rul|
|000020e0| 65 73 20 3d 20 52 75 6c | 00 00 00 00 00 00 00 00 |es = Rul|........|
|000020f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+